#ifndef X32_H
#define X32_H

#include "common.h"

// Symbol pins
template <AllegroVersion version>
struct x32
{
    uint16_t type;
    uint8_t subtype;
    uint8_t layer;
    
    uint32_t k;
    uint32_t un1;
    
    uint32_t ptr1;
    
    // Don't look for layer here, seems almost always null.
    uint32_t bitmask1;
    
    uint32_t next;
    
    uint32_t ptr3;
    uint32_t ptr4;
    uint32_t ptr5;
    uint32_t ptr6;
    uint32_t ptr7;
    uint32_t ptr8;
    
    uint32_t previous;
    
    uint32_t ptr10;
    uint32_t ptr11;
    
    int32_t coords[4];
    
    uint32_t TAIL;
    operator x32<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};

#if __cplusplus >= 202002L
template <AllegroVersion version> requires(version >= A_172)
struct x32<version>
{
    uint16_t type;
    uint8_t subtype;
    uint8_t layer;

    uint32_t k;
    uint32_t un1;

    uint32_t ptr1;

    // Don't look for layer here, seems almost always null.
    uint32_t bitmask1;

    uint32_t prev;
    uint32_t next;

    uint32_t ptr3;
    uint32_t ptr4;
    uint32_t ptr5;
    uint32_t ptr6;
    uint32_t ptr7;
    uint32_t ptr8;

    uint32_t previous;

    uint32_t un2;

    uint32_t ptr10;
    uint32_t ptr11;

    int32_t coords[4];

    uint32_t TAIL;
    operator x32<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};
#else
template <> struct x32<A_172>
{
    uint16_t type;
    uint8_t subtype;
    uint8_t layer;

    uint32_t k;
    uint32_t un1;

    uint32_t ptr1;

    // Don't look for layer here, seems almost always null.
    uint32_t bitmask1;

    uint32_t prev;
    uint32_t next;

    uint32_t ptr3;
    uint32_t ptr4;
    uint32_t ptr5;
    uint32_t ptr6;
    uint32_t ptr7;
    uint32_t ptr8;

    uint32_t previous;

    uint32_t un2;

    uint32_t ptr10;
    uint32_t ptr11;

    int32_t coords[4];

    uint32_t TAIL;
    operator x32<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};
template <> struct x32<A_174> : x32<A_172> {};
#endif

#endif // X32_H
